﻿namespace ESoft.Specification
{
    // 规约接口的定义
    public interface ISpecification<T>
    {
        /// <summary>
        /// 是否安全
        /// </summary>
        /// <param name="candidate"></param>
        /// <returns></returns>
        bool IsSatisfiedBy(T candidate);

        /// <summary>
        /// And 规约
        /// </summary>
        /// <param name="specification"></param>
        /// <returns></returns>
        ISpecification<T> And(ISpecification<T> specification);

        /// <summary>
        /// 或 规约
        /// </summary>
        /// <param name="specification"></param>
        /// <returns></returns>
        ISpecification<T> Or(ISpecification<T> specification);

        /// <summary>
        /// 非规约
        /// </summary>
        /// <param name="specification"></param>
        /// <returns></returns>
        ISpecification<T> Not(ISpecification<T> specification);
    }
}
